/*
 * $Id: NavigationLoader.java 56 2009-05-11 10:11:46Z donbeave $
 */

package labour.dbmanager.client.data;

import labour.dbmanager.client.connector.NavigationConnector;
import labour.dbmanager.client.model.Schema;
import labour.dbmanager.client.model.Table;

import com.extjs.gxt.ui.client.data.BaseTreeLoader;
import com.extjs.gxt.ui.client.data.ModelData;

public class NavigationLoader<M extends ModelData> extends BaseTreeLoader<M> {

  public NavigationLoader(NavigationConnector connector) {
    super(connector.getProxy(), connector.getReader());
  }

  @Override
  public boolean hasChildren(M parent) {
    if (parent instanceof Schema) {
      return ((Schema) parent).hasTables();
    }
    else if (parent instanceof Table) {
      return ((Table) parent).hasColumns();
    }

    return super.hasChildren(parent);
  }

}
